/**
 * 2032. 至少在两个数组中出现的值
 * @param {number[]} nums1
 * @param {number[]} nums2
 * @param {number[]} nums3
 * @return {number[]}
 */
var twoOutOfThree = function (nums1, nums2, nums3) {
	const map = new Map()
	for (const num of nums1) {
		map.set(num, 1)
	}
	for (const num of nums2) {
		map.set(num, (map.get(num) || 0) | 2)
	}
	for (const num of nums3) {
		map.set(num, (map.get(num) || 0) | 4)
	}
	const res = []
	for (const [k, v] of map.entries()) {
		if ((v & (v - 1)) !== 0) {
			res.push(k)
		}
	}
	return res
}

var twoOutOfThree = function (nums1, nums2, nums3) {
	const st = new Set(nums1)
	const st2 = new Set(nums2)
	const st3 = new Set(nums3)
	const ans = new Set()
	for (let c of st2) {
		if (st.has(c)) {
			ans.add(c)
		} else {
			st.add(c)
		}
	}
	for (let c of st3) {
		if (st.has(c)) {
			ans.add(c)
		}
	}

	return Array.from(ans)
}
const res = twoOutOfThree([1, 1, 3, 2], [2, 3], [3])
console.log('twoOutOfThree :>>', res)
